import { request } from './request'

export const pageArticle = (params: App.PageArticleParams): Promise<App.PageResponse<App.ArticleItem>> => {
  return request({
    method: 'post',
    data: params,
    url:'/article/page'
  })
}

export const addOrUpdateArticle = (params: App.ArticleItem):Promise<App.ResponseCore>=>{
  return request({
    method: 'post',
    data: params,
    url:'/article/addOrUpdate'
  })
}

export const detailArticle = (params: App.DetailParams):Promise<App.ArticleItem> => {
  return request({
    method: 'get',
    params,
    url:"/article/detail"
  })
}

export const deleteArticle = (params: App.DetailParams): Promise<App.ResponseCore> => {
  return request({
    method: 'get',
    params,
    url:'/article/delete'
  })
}

export const likeArticle = (params: App.DetailParams): Promise<App.ResponseCore> => {
  return request({
    method: 'get',
    params,
    url:'/article/like'
  })
}


export const likeNum = (params: App.DetailParams): Promise<number> => {
  return request({
    method: 'get',
    params,
    url:'/article/like-num'
  })
}

export const typePage = (params:App.PageArticleParams): Promise<App.PageResponse<App.ArticleTypeItem>> => {
  return request({
    method: 'post',
    data:params,
    url:'/article-type/page'
  })
}

export const deleteType = (params:App.DetailParams):Promise<App.ResponseCore> => {
  return request({
    method: 'get',
    params,
    url:'/article-type/delete'
  })
}

export const addOrUpdateArticleType = (params: App.ArticleTypeItem):Promise<App.ResponseCore>=>{
  return request({
    method: 'post',
    data: params,
    url:'/article-type/addOrUpdate'
  })
}

export const typeList = (): Promise<App.ResponseCore<App.ArticleTypeItem[]>> => {
  return request({
    method: 'get',
    url:'/article-type/list'
  })
}

export const getTagGroup = ():Promise<App.ArticleTagGroupItem[]> => {
  return request({
    method: 'get',
    url:'/article/tag-group'
  })
}